package com.ruoyi.cbs.contract.service.impl;

import java.util.List;

import com.ruoyi.cbs.contract.domain.ContractorDocument;
import com.ruoyi.cbs.contract.mapper.ContractorDocumentMapper;
import com.ruoyi.cbs.contract.service.IContractorDocumentService;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.uuid.IdFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 承包商资料Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-10-31
 */
@Service
public class ContractorDocumentServiceImpl implements IContractorDocumentService
{
    @Autowired
    private ContractorDocumentMapper contractorDocumentMapper;

    /**
     * 查询承包商资料
     * 
     * @param id 承包商资料主键
     * @return 承包商资料
     */
    @Override
    public ContractorDocument selectContractorDocumentById(Long id)
    {
        return contractorDocumentMapper.selectContractorDocumentById(id);
    }

    /**
     * 查询承包商资料列表
     *
     * @param contractorId 承包商ID
     * @return 承包商资料
     */
    @Override
    public List<ContractorDocument> selectListByContractorId(Long contractorId)
    {
        ContractorDocument contractorDocument = new ContractorDocument();
        contractorDocument.setContractorId(contractorId);
        contractorDocument.setStatus("1");
        return contractorDocumentMapper.selectContractorDocumentList(contractorDocument);
    }

    /**
     * 查询承包商资料列表
     * 
     * @param contractorDocument 承包商资料
     * @return 承包商资料
     */
    @Override
    public List<ContractorDocument> selectContractorDocumentList(ContractorDocument contractorDocument)
    {
        return contractorDocumentMapper.selectContractorDocumentList(contractorDocument);
    }

    /**
     * 新增承包商资料
     * 
     * @param contractorDocument 承包商资料
     * @return 结果
     */
    @Override
    public int insertContractorDocument(ContractorDocument contractorDocument)
    {
        contractorDocument.setCreateTime(DateUtils.getNowDate());
        contractorDocument.setId(IdFactory.newLongId());
        if (contractorDocument.getCreateBy() == null) {
            contractorDocument.setCreateBy("admin");
        }
        return contractorDocumentMapper.insertContractorDocument(contractorDocument);
    }

    /**
     * 修改承包商资料
     * 
     * @param contractorDocument 承包商资料
     * @return 结果
     */
    @Override
    public int updateContractorDocument(ContractorDocument contractorDocument)
    {
        contractorDocument.setUpdateTime(DateUtils.getNowDate());
        return contractorDocumentMapper.updateContractorDocument(contractorDocument);
    }

    /**
     * 批量删除承包商资料
     * 
     * @param ids 需要删除的承包商资料主键
     * @return 结果
     */
    @Override
    public int deleteContractorDocumentByIds(Long[] ids)
    {
        return contractorDocumentMapper.deleteContractorDocumentByIds(ids);
    }

    /**
     * 删除承包商资料信息
     * 
     * @param id 承包商资料主键
     * @return 结果
     */
    @Override
    public int deleteContractorDocumentById(Long id)
    {
        return contractorDocumentMapper.deleteContractorDocumentById(id);
    }
}
